<template>
  <div>
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path: '/reports' }">数据统计</el-breadcrumb-item>
      <el-breadcrumb-item>数据报表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card>
      <div id="mian" style="width: 750px;height: 400px;"></div>
    </el-card>
  </div>
</template>

<script>
import echarts from 'echarts'
import _ from 'lodash'

export default {
  created () {},
  data () {
    return {
      option: {
        title: {
          text: '用户来源'
        },
        xAxis: [{
          boundaryGap: false
        }],
        yAxis: [{
          type: 'value'
        }],
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross',
            label: {
              backgroundColor: '#E9EEF3'
            }
          }
        }
      }
    }
  },
  async mounted () {
    const myecharts = echarts.init(document.querySelector('#mian'))
    const {
      data: res
    } = await this.$http.get('http://kb.dekunlu.top/api/private/v1/reports/type/1')
    if (res.meta.status !== 200) return this.$message.error('获取数据失败')
    const rester = _.merge(res.data, this.option)
    myecharts.setOption(rester)
  },
  methods: {

  }
}
</script>

<style lang="less" scoped>
  #mian {
    margin: 0 auto;
  }
</style>
